﻿'Interface créer par Caroline St-Yves
'Programmez par Caroline St-Yves
'Date de création : 7 septembre 2012, 8h00 am.
'Date dernière modification : 5 octobre 2012, 12h10.
Public Class ListeEmployes
    Dim oLocalContext As DBMainContext

    Private Sub ListeEmployes_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        oLocalContext = New DBMainContext
        dgvEmployes.DataSource = oLocalContext.Employe
        AfficherColonne()


    End Sub
    Sub AfficherColonne()

        With dgvEmployes
            .Columns("NomComplet").DisplayIndex = 1
            .Columns("NomComplet").HeaderText = "Nom complet"
            .Columns("ID").Visible = False
            .Columns("Nom").Visible = False
            .Columns("Prenom").Visible = False
            .Columns("DateEmbauche").Visible = True
            .Columns("DateEmbauche").HeaderText = "Date d'embauche"
            .Columns("NAS").Visible = False
            .Columns("Voiture").Visible = False
            .Columns("TypeVoiture").Visible = False
            .Columns("ID_TypeEmploye").Visible = False
            .Columns("Adresse").Visible = False
            .Columns("Ville").Visible = False
            .Columns("Code_Postal").Visible = False
            .Columns("Province").Visible = False
            .Columns("Pays").Visible = False
            .Columns("TelBureau").Visible = False
            .Columns("TelCellulaire").Visible = False
            .Columns("Courriel").Visible = False
            .Columns("Finance_Succursale").Visible = False
            .Columns("Finance_Transit").Visible = False
            .Columns("Finance_Folio").Visible = False
            .Columns("NoPermiConduire").Visible = False
            .Columns("NombreHre").Visible = False
            .Columns("Note").Visible = False
            .Columns("Login").Visible = False
            .Columns("MotDePasse").Visible = False
            .Columns("tx_Hor").Visible = False
            .Columns("Photo").Visible = False
            .Columns("TelPoste").Visible = False
            .Columns("ID_Formation").Visible = False
            .Columns("ID_Interet").Visible = False
            '.Columns("Disponibilite_Employe").Visible = False
            .Columns("Employe_Disponibilite_Ponctuel").Visible = False
            .Columns("Type_Employe").Visible = False
            .Columns("Poste").Visible = False
            .Columns("PosteModif").DisplayIndex = 30
            .Columns("Postemodif").HeaderText = "Poste"
            .Columns("DateNaissance").DisplayIndex = 2
            .Columns("DateNaissance").HeaderText = "Date de naissance"
            .Columns("TelMaison").HeaderText = "Téléphone à domicile"
            .Columns("ID_Poste").Visible = False

        End With
        
    End Sub

    Private Sub btnAjouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAjouter.Click
        Dim oNewIEmp As New FicheEmploye()
        MainForm.AddTabToTC("Employe X", True, oNewIEmp)
    End Sub

    Private Sub dgvEmployes_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgvEmployes.DoubleClick
        Dim oEmp As Employe
        oEmp = CType(dgvEmployes.SelectedRows(0).DataBoundItem, Employe)
        Dim oNewIEmp As New FicheEmploye(oEmp)
        MainForm.AddTabToTC("Employé:" + oEmp.Nom + "," + oEmp.Prenom, True, oNewIEmp)
    End Sub

    Private Sub btnOuvrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOuvrir.Click
        Dim oEmp As Employe
        oEmp = CType(dgvEmployes.SelectedRows(0).DataBoundItem, Employe)
        Dim oNewIEmp As New FicheEmploye(oEmp)
        MainForm.AddTabToTC("Employé:" + oEmp.Nom + "," + oEmp.Prenom, True, oNewIEmp)
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb_Actif.CheckedChanged
        dgvEmployes.DataSource = (From u In oLocalContext.Employe Where u.Actif = Not rbInactif.Checked Select u)
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rbInactif.CheckedChanged
        dgvEmployes.DataSource = (From u In oLocalContext.Employe Where u.Actif = Not rbInactif.Checked Select u)
    End Sub

    Private Sub rb_All_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rb_All.CheckedChanged
        dgvEmployes.DataSource = (From u In oLocalContext.Employe Select u)
    End Sub
End Class
